package cc.idoone.spring_boot_hello.jdbc.service;

import cc.idoone.spring_boot_hello.jdbc.dao.RoleDao;
import cc.idoone.spring_boot_hello.jdbc.jpa.RoleBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 事务示例
 *
 * @auther hemj
 * @since 2017/9/23
 */
@Service
@Transactional(transactionManager = "jdbcManager")
public class JdbcService {
	@Autowired
	private RoleDao roleDao;

	@Transactional(readOnly = true)
	public List<RoleBean> findAll() {
		return roleDao.findAll();
	}

	@Transactional(readOnly = true)
	public RoleBean findRoleById(String id) {
		return roleDao.findRoleById(id);
	}

	public RoleBean create(final RoleBean role) {
		return roleDao.create(role);
	}

	public void update(final RoleBean role) {
		roleDao.update(role);
	}

	public void delete(final String id) {
		roleDao.delete(id);
	}
}
